package com.dragonwu.constant;

/**
 * 登录常量
 *
 * @author DragonWu
 * @since 2022-10-10 12:58
 **/
public class LoginConstant {

    /*
    后台管理人员
     */
    public static final String ADMIN_TYPE = "admin_type";

    /*
    普通的用户
     */
    public static final String MEMBER_TYPE = "member_type";

    /*
    使用用户名查询用户
     */
    public static final String QUERY_ADMIN_SQL =
            "select `id`,`username`,`password`,`status` from sys_user where username=?";

    /*
    查询用户的角色
     */
    public static final String QUERY_ROLE_CODE_SQL =
            "select `code` from sys_role left join sys_user_role on sys_role.id=sys_user_role.id where sys_user_role.user_id=?";

    /*
    查询所有权限名称
     */
    public static final String QUERY_ALL_PERMISSIONS =
            "select `name` from sys_privilege";

    /*
    对应非超级管理员，我们需要先查询role->permissionId->permission
     */
    public static final String QUERY_PERMISSION_SQL =
            "SELECT `name` FROM sys_privilege LEFT JOIN sys_role_privilege ON sys_role_privilege.privilege_id = sys_privilege.id LEFT JOIN sys_user_role  ON sys_role_privilege.role_id = sys_user_role.role_id WHERE sys_user_role.user_id = ?";

    /*
    超级管理员角色的code
     */
    public static final String ADMIN_ROLE_CODE = "ROLE_ADMIN";

    /*
    用户查询SQL
     */
    public static final String QUERY_MEMBER_SQL =
            "select `id`,`password`,`status` from `user` where mobile=? or email=?";

    public static final String REFRESH_TYPE = "REFRESH_TOKEN";

    /*
     使用用户的id 查询用户名称
     */
    public static final String QUERY_ADMIN_USER_WITH_ID = "SELECT `username` FROM sys_user where id = ?";

    /*
     使用用户的id 查询用户名称
     */
    public static final String QUERY_MEMBER_USER_WITH_ID = "SELECT `mobile` FROM user where id = ?";
}
